package cn.e3mall.portal.exception;


import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.servlet.HandlerExceptionResolver;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class GlobalException implements HandlerExceptionResolver {

    private final Logger logger = LoggerFactory.getLogger(GlobalException.class);
    @Override
    public ModelAndView resolveException(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object o, Exception e) {
        //控制台打印
        e.printStackTrace();
//        写日志
        logger.error("系统异常",e);
        //发邮件jmail工具包
        //发短信
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.setViewName("error/exception");
        return modelAndView;
    }
}
